package com.ruoyi.web.controller.wfshou;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wfshou.domain.ProjPrac;
import com.ruoyi.wfshou.service.IProjPracService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 综合实践类项目Controller
 * 
 * @author zongying
 * @date 2023-06-19
 */
@RestController
@RequestMapping("/wfshou/Projprac")
public class ProjPracController extends BaseController
{
    @Autowired
    private IProjPracService projPracService;

    /**
     * 查询综合实践类项目列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprac:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProjPrac projPrac)
    {
        startPage();
        List<ProjPrac> list = projPracService.selectProjPracList(projPrac);
        return getDataTable(list);
    }

    /**
     * 导出综合实践类项目列表
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprac:export')")
    @Log(title = "综合实践类项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProjPrac projPrac)
    {
        List<ProjPrac> list = projPracService.selectProjPracList(projPrac);
        ExcelUtil<ProjPrac> util = new ExcelUtil<ProjPrac>(ProjPrac.class);
        util.exportExcel(response, list, "综合实践类项目数据");
    }

    /**
     * 获取综合实践类项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprac:query')")
    @GetMapping(value = "/{pracId}")
    public AjaxResult getInfo(@PathVariable("pracId") Long pracId)
    {
        return success(projPracService.selectProjPracByPracId(pracId));
    }

    /**
     * 新增综合实践类项目
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprac:add')")
    @Log(title = "综合实践类项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProjPrac projPrac)
    {
        return toAjax(projPracService.insertProjPrac(projPrac));
    }

    /**
     * 修改综合实践类项目
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprac:edit')")
    @Log(title = "综合实践类项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProjPrac projPrac)
    {
        return toAjax(projPracService.updateProjPrac(projPrac));
    }

    /**
     * 删除综合实践类项目
     */
    @PreAuthorize("@ss.hasPermi('wfshou:Projprac:remove')")
    @Log(title = "综合实践类项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{pracIds}")
    public AjaxResult remove(@PathVariable Long[] pracIds)
    {
        return toAjax(projPracService.deleteProjPracByPracIds(pracIds));
    }
}
